<?php

/**
 * User password recovery form
 *
 */
class Application_Form_Recover extends Zend_Form
{

    public function init()
    {
        $this->setMethod('POST');
        $this->setAction(Zend_Registry::get('view')->fixUrl('user/recover'));
        
        $login=new Zend_Form_Element_Text('login');
        $login->setLabel('Login')
              ->addFilter('StringTrim')
              ->addValidator('StringLength', 
                              true, 
                              array(
                                    'min' => 4,
                                    'max'=> 255
                                    )
                              )
               ->addDecorator(new Application_Form_RecoverDecorator())
               ->setRequired(true);
        
        $email=new Zend_Form_Element_Text('email');
        $email->setLabel('E-Mail')
              ->addFilter('StringTrim')
              ->addValidator(
                    'EmailAddress',
                    true
              )
              ->addValidator(
                    new Application_Form_RecoverValidator(),
                    true
              )
              ->addDecorator(new Application_Form_RecoverDecorator())
              ->setRequired(true);
         
         $this->addElements(
            array(
                $login,
                $email
                )
         );
        
         $this->addElement('captcha', 'captcha', array(
            'label'      => 'CAPTCHA',
            'captcha'    => array(
                'captcha' => 'Image',
                'font' => $_SERVER['DOCUMENT_ROOT'].'/data/misc/FreeSerifBold.ttf',
                'fontSize' => 24,
                'imgDir' => $_SERVER['DOCUMENT_ROOT'].'/data/tmp/captcha',
                'imgUrl' => Zend_Registry::get('view')->baseUrl('data/tmp/captcha'),
                'wordLen' => 6,
                'timeout' => 300,
                'width' => 200,
                'height' => 50
            ),
            'decorators' => array(
                                new Application_Form_RecoverDecorator()
                              ),
            'required'   => true
         ));
               
         $submit=new Zend_Form_Element_Submit('submit');
         $submit->setValue('Recover')
                ->setLabel('')
                ->addDecorator(new Application_Form_RecoverDecorator());
               
         $csrf=new Zend_Form_Element_Hash('csrf',array('salt' => 'userRecover'));
         $csrf->setOptions(array(
                            'ignore' => true,
                        ))
              ->addDecorator(new Application_Form_RecoverDecorator());
              
        $this->addElements(
            array(
                $submit,
                $csrf
                )
        );
    }
}

